package com.plant.physician.service.impl;

import com.plant.physician.domain.Physician;
import com.plant.physician.mapper.PhysicianMapper;
import com.plant.physician.service.PhysicianService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class PhysicianServiceImpl implements PhysicianService {
    @Autowired
    private PhysicianMapper physicianMapper;
    @Override
    public void insert(Physician physician) {
        physician.setSubTime(new Date());
        physician.setDel(0);
        physician.setStatus(0);
        physicianMapper.insert(physician);
    }

    @Override
    public Physician findById(Integer userId) {
        return physicianMapper.findById(userId);
    }

    @Override
    public List<Physician> selectPhy() {
        return physicianMapper.selectPhy();
    }

    @Override
    @Transactional
    public void updateStatus(Physician physician) {
        physician.setByTime(new Date());
        physicianMapper.updateStatus(physician);
        physicianMapper.updateUserStatus(physician);
    }
    @Override
    public List<Physician> findAll() {
        return physicianMapper.findAll();
    }
}
